/*
 * @Author: 严晗 823841034@qq.com
 * @Date: 2023-10-11 17:20:17
 * @LastEditors: 严晗 823841034@qq.com
 * @LastEditTime: 2023-11-09 17:11:33
 * @FilePath: /yike-admin/Users/yanhan/vite-project/src/composables/utils.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { ElNotification, ElMessageBox } from 'element-plus'
import nprogress from 'nprogress'

// 消息提示
export function toast(message, type = 'success', dangerouslyUseHTMLString = false) {
	ElNotification({
		message,
		type,
		dangerouslyUseHTMLString,
		duration: 3000,
	})
}

// 确认框提示
export function showModel(content, title = '提示', type = 'warning') {
	return ElMessageBox.confirm(content, title, {
		confirmButtonText: '确认',
		cancelButtonText: '取消',
		type
	})
}

// 打开全局loading
export function showFullLoading(){
	nprogress.start()
}

// 关闭全局loading
export function hideFullLoading(){
	nprogress.done()
}

// 获取屏幕大小，进行侧边栏适配
export function getScreen () {
	var width = document.body.clientWidth;
	if (width >= 1200) {
			return 3; //大屏幕
	} else if (width >= 992) {
			return 2; //中屏幕
	} else if (width >= 768) {
			return 1; //小屏幕
	} else {
			return 0; //超小屏幕
	}
}